<?php
class Bootstrap 
{
	/** METHODS FOR ACCORDION COMPONENT **/
	public static function accordion_start($id)
	{
		$html = "";
		$html .= "<div class='accordion' id='".$id."'>";
		return $html;		
	}

	public static function accordion_end()
	{
		$html = "";
		$html .= "</div>";
		return $html;
	}

	public static function accordion_group_start($id, $heading, $collapse, $collapsed="")
	{
		$html = "";
		$html .= "<div class='accordion-group'>";

		$html .= "<div class='accordion-heading'>";
		$html .= "<a class='accordion-toggle' data-toggle='collapse' data-parent='#".$id."' href='#".$collapse."'>";
		$html .= $heading;
		$html .= "</a>";
		$html .= "</div>";

		$html .= "<div id='".$collapse."' class='accordion-body collapse ".$collapsed."'>";
		$html .= "<div class='accordion-inner'>";
		return $html;		
	}

	public static function accordion_group_end()
	{
		$html = "</div></div></div>";
		return $html;			
	}


	/** METHODS FOR TAB COMPONENT **/
	public static function tabbable_start()
	{
		$html = "<div class='tabbable'>";
		return $html;	
	}

	public static function tabbable_end()
	{
		$html = "</div>";
		return $html;
	}

	public static function tabbable_navtabs_start($id) 
	{
		$html = "<ul class='nav nav-tabs' id='".$id."'>";
		return $html;
	}

	public static function tabbable_tab($title, $href, $active="")
	{
		$html = "<li class='".$active."'><a href='#".$href."' data-toggle='tab'>".$title."</a></li>";
		return $html;
	}

	public static function tabbable_navtabs_end() 
	{
		$html = "</ul></div>";
		return $html;
	}

	public static function tabbable_content_start()
	{
		$html = "<div class='tab-content'>";
		return $html;
	}

	public static function tabbable_content_end()
	{
		$html = "</div>\n<!-- tabbable content end -->";
		return $html;
	}

	public static function tabbable_pane_start($id, $active="")
	{
		$html = "<div class='tab-pane ".$active."'' id='".$id."'>";
		return $html;
	}

	public static function tabbable_pane_end()
	{
		$html = "</div>";
		return $html;
	}

	/** METHODS FOR FORM COMPONENTS **/
	public static function form_text($name, $label, $default="", $errorMsg="", $max_chars=null)
	{
		$html = "";
		$html .= "<div class='control-group ";
		if(trim($errorMsg) != "") { $html .= "error"; }
		$html .= "'>";
		$html .= "<label for='".$name."' class='control-label'>";
		$html .= $label;
		$html .= "</label>";
		$html .= "<div class='controls'>";
		$html .= Form::text($name, Input::old($name, $default), array('class' => 'input-block-level', 'id' => $name));
		if(trim($errorMsg) != "") { $html .= "<span class='help-inline'>".$errorMsg."</span>"; }
		if($max_chars != null) {
			$html .= "Kalan <span class='counter' id='".$name."_counter'>0</span> Karakter (max ".$max_chars." karakter kullanabilirsiniz.)";
		}
		$html .= "</div>";
		$html .= "</div>";
		return $html;
	}

	/** METHODS FOR FORM COMPONENTS **/
	public static function form_textarea($name, $label, $default="", $errorMsg="", $max_chars=null)
	{
		$html = "";
		$html .= "<div class='control-group ";
		if(trim($errorMsg) != "") { $html .= "error"; }
		$html .= "'>";
		$html .= "<label for='".$name."' class='control-label'>";
		$html .= $label;
		$html .= "</label>";
		$html .= "<div class='controls'>";
		$html .= Form::textarea($name, Input::old($name, $default), array('class' => 'input-block-level', 'id' => $name));
		if(trim($errorMsg) != "") { $html .= "<span class='help-inline'>".$errorMsg."</span>"; }
		if($max_chars != null) {
			$html .= "Kalan <span class='counter' id='".$name."_counter'>0</span> Karakter (max ".$max_chars." karakter kullanabilirsiniz.)";
		}		
		$html .= "</div>";
		$html .= "</div>";
		return $html;
	}

	public static function form_upload_image($name, $default=null) 
	{
		$html = "";
		$html .= "<div class='fileupload fileupload-new' data-provides='fileupload'>";
		$html .= "<div class='fileupload-new thumbnail' style='width: 50px; height: 50px;'>";

		if($default != null) {
			$html .= HTML::image($file, array('style'=>"width:50px; height:50px;"));
		} else {
			$html .= "<img src='http://www.placehold.it/50x50/EFEFEF/AAAAAA' />";
		}
		$html .= "</div>";
		$html .= "<div class='fileupload-preview fileupload-exists thumbnail' style='width: 50px; height: 50px;'></div>";
		$html .= "<span class='btn btn-file'><span class='fileupload-new'>Resim Seçin</span><span class='fileupload-exists'>Değiştir</span>";
		$html .= "<input type='file' name='".$name."' /></span>";
		$html .= "<a href='#' class='btn fileupload-exists' data-dismiss='fileupload'>Sil</a>";
		$html .= "</div>";
		return $html;	
	}

} 